// -----------------------------------------------------------------------
//  <copyright file="ISpecification.cs" company="LiuliuSoft">
//      Copyright (c) 2022-2024 DaprPlus. All rights reserved.
//  </copyright>
//  <site>https://dapr.plus</site>
//  <last-editor>郭明锋</last-editor>
//  <last-date>2024/12/6 15:47:11</last-date>
// -----------------------------------------------------------------------

using DaprPlus.Domain.Entity;


namespace DaprPlus.Specifications;

/// <summary>
/// 定义一个查询规约
/// </summary>
public interface ISpecification<T> where T : IEntity
{
    /// <summary>
    /// 查询条件表达式
    /// </summary>
    Expression<Func<T, bool>> Criteria { get; }

    /// <summary>
    /// 预加载导航属性表达式
    /// </summary>
    IReadOnlyList<Expression<Func<T, object>>> Includes { get; }

    /// <summary>
    /// 预加载导航属性字符串
    /// </summary>
    IReadOnlyList<string> IncludeStrings { get; }

    /// <summary>
    /// 排序条件表达式及方向列表
    /// </summary>
    IReadOnlyList<(Expression<Func<T, object>> OrderByExpression, bool IsDescending)> OrderExpressions { get; }

    /// <summary>
    /// 字符串的排序条件及方向列表
    /// </summary>
    IReadOnlyList<(string FieldName, bool IsDescending)> OrderStrings { get; }

    bool IsPagingEnabled { get; }

    int Take { get; }

    int Skip { get; }

    ISpecification<T> And(ISpecification<T> specification);

    ISpecification<T> Or(ISpecification<T> specification);

    ISpecification<T> Not();

    ISpecification<T> AndNot(ISpecification<T> specification);

    ISpecification<T> OrNot(ISpecification<T> specification);
}
